package edu.wuster.blog.controller;

import edu.wuster.blog.entity.Report;
import edu.wuster.blog.entity.Result;
import edu.wuster.blog.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/*
* 举报控制类
* */


@CrossOrigin
@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {
    @Autowired
    ReportService reportService;

    //删除举报信息
    @DeleteMapping("/{id}")
    public Result deleteById(@PathVariable Integer id) {
        log.info("删除举报信息");
        reportService.deleteById(id);
        log.info("删除举报信息成功");
        return Result.success();
    }

    //新增举报信息
    @PostMapping
    public Result addReport(@RequestBody Report report) {
        log.info("新增举报信息");
        reportService.addReport(report);
        log.info("新增举报信息成功");
        return Result.success();
    }

    //查询举报信息
    @GetMapping
    public Result select() {
        log.info("管理员查询举报信息");
        List<Report> list = reportService.select();
        log.info("管理员查询举报信息成功");
        return Result.success(list);
    }
}
